addpath('../lib');
addpath('../mockData');

disp('initial computations');


niter = 400;

t = 0:0.3:10; %laikas
lam = 100:10:700; %bangos ilgiai

size(t)
size(lam)

disp(size(t));
disp(size(lam));

spec = MockWGaussian(lam);
conc = MockHSimple(t);

PlotW(lam, spec, 'pradInfo');
PlotH(t, conc, 'pradInfo');



duomenys=spec*conc;

PlotMain(lam, t, duomenys, 'initialOveral');
R = 3;

[M N] = size(duomenys);
[W0 H0] = GetStartingWHStatic(M, N, R);

%% standart NMF
disp('Computing NMF');
[W1 H1] = NMF(duomenys, R, niter);
PlotW(lam, W1, 'nmf');
PlotH(t, H1, 'nmf');
PlotMain(lam,t, W1*H1, 'nmf');
PlotMain(lam,t, duomenys - W1*H1, 'nmfDelta', 'norm', 0);
disp('Finished');

%% standart NMF
disp('Computing CNMF');
[W1 H1] = CNMF(duomenys, R, niter, 'W0', W0, 'H0', H0, 'alpha', 10);
PlotW(lam, W1, 'cnmf');
PlotH(t, H1, 'cnmf');
PlotMain(lam,t, W1*H1, 'cnmf');
PlotMain(lam,t, duomenys - W1*H1, 'cnmfDelta', 'norm', 0);
disp('Finished');

%% standart NMF
disp('Computing LSNMF');
[W1 H1] = nnmf(duomenys, R, 'w0', W0, 'h0', H0);
%[W1 H1] = LSNMF(duomenys, R, niter, 'W0', W0, 'H0', H0);
PlotW(lam, W1, 'lsnmf');
PlotH(t, H1, 'lsnmf');
PlotMain(lam,t, W1*H1, 'lsnmf');
PlotMain(lam,t, duomenys - W1*H1, 'lsnmfDelta', 'norm', 0);
disp('Finished');

%% standart NMF
disp('Computing KLNMF');
[W1 H1] = KLNMF(duomenys, R, niter, 'W0', W0, 'H0', H0);
PlotW(lam, W1, 'klnmf');
PlotH(t, H1, 'klnmf');
PlotMain(lam,t, W1*H1, 'klnmf');
PlotMain(lam,t, duomenys - W1*H1, 'klnmfDelta', 'norm', 0);
disp('Finished');
